package com.rc.saas.tenant.service.enterprise;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.enterprise.RcEnterpriseLevelSettingMapper;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseLevelSetting;
import com.rc.saas.tenant.model.enterprise.RcEnterpriseLevelSettingExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class RcEnterpriseLevelSettingServiceImpl implements  RcEnterpriseLevelSettingService{

    @Autowired
    private RcEnterpriseLevelSettingMapper enterpriseLevelSettingMapper;

    @Override
    public RcEnterpriseLevelSettingMapper getMapper() {
        return enterpriseLevelSettingMapper;
    }

    @Override
    public PageInfo<RcEnterpriseLevelSetting> listPageLevelSetting(String levelName, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<RcEnterpriseLevelSetting> list = enterpriseLevelSettingMapper.listLevelSetting(levelName);
        return new PageInfo<>(list);
    }

    @Override
    public void updateLevelSetting(RcEnterpriseLevelSetting enterpriseLevelSetting) {
        enterpriseLevelSettingMapper.updateByPrimaryKeySelective(enterpriseLevelSetting);
    }

    @Override
    public void addLevelSetting(RcEnterpriseLevelSetting enterpriseLevelSetting) {
        enterpriseLevelSettingMapper.insertSelective(enterpriseLevelSetting);
    }

    @Override
    public List<RcEnterpriseLevelSetting> listLevel() {
        RcEnterpriseLevelSettingExample example = new RcEnterpriseLevelSettingExample();
        List<RcEnterpriseLevelSetting> levels = enterpriseLevelSettingMapper.selectByExample(example);
        return levels;
    }

    @Override
    public RcEnterpriseLevelSetting selectLevelBetweenInterval(BigDecimal money) {
        return enterpriseLevelSettingMapper.selectLevelBetweenInterval(money);
    }
}
